# -*- coding:utf-8 -*-

# @Time    : 2023/9/20 21:07
# @Author  : yaodong
# @Email   : yaodong@lingxi.ai
# @Software: LLM_internal

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


import asyncio
import copy
import json
import pandas as pd
import redis
import math
import urllib

from common.log import logger
from db.redis.redis_service import RedisMemory
from urllib.parse import urlparse, parse_qs

if __name__ == '__main__':

    redis_memory = RedisMemory()
    # 读取Excel文件
    excel_file = "/Users/yaodong/Desktop/字典项2.xlsx"
    df = pd.read_excel(excel_file)

    # 创建一个字典来存储数据
    data_dict = {}

    # 循环遍历DataFrame中的每一行
    for index, row in df.iterrows():
        chinese_key = row.iloc[0]   # 第一列作为中文键
        english_key = row.iloc[1]  # 第二列作为英文键

        # 将键值对存储到字典
        data_dict[chinese_key] = english_key

    # 存储到Redis中
    redis_key = "dict"  # 外层键名
    for key, inner_hash in data_dict.items():
        redis_memory.set_memory(redis_key, key, inner_hash)

    # 打印结果
    print("数据已存储到Redis中。")
